import { tableOption } from './successfulTrade.config.js'
import search from './../search/search.js';
import { shopCheckcharge } from '@/api/shop/storeReport.js'
export default {
    name: "successfulTrade",
    mixins: [search],
    data() {
        return {
            tableOption: tableOption,
            loading: false,
            loadData: [],
            page: {
                total: 0,
                size: 10,
                current: 1,
            },

            searchForm: {}
        }
    },
    methods: {
        getList(searchForm, page) {
            if (searchForm) {
                console.log(searchForm)
                this.searchForm = searchForm
            }
            if (page) {
                this.page.current = page
            }
            shopCheckcharge(Object.assign({ shopId: this.$route.query.shopId,beginTime:this.$route.query.beginTime,endTime:this.$route.query.endTime }, this.searchForm, this.page)).then(val => {
               
                let data = val.data
                this.loadData = data.records
                this.page = {
                    total: data.total,
                    size: data.size,
                    current: data.current,
                };
                this.loadData.forEach(item => {
                    if (item.businessType) {
                        item.businessType3 = []
                        item.businessType2 = item.businessType.split(',')
                        item.businessType2.forEach(i => {
                            this.$store.getters.businessTypeList.forEach(m => {
                                if (i == m.value) {
                                    item.businessType3.push(m.label)

                                }
                            })
                        })
                        item.businessType1 = item.businessType3.join(',')
                    }
                })
                console.log(this.loadData)
            })
        },
        onShowSizeChange(current, size) {
            console.log(current, size)
            this.page.current = current
            this.page.size = size
            this.getList()
        },
    },
    filters: {
        accountType(val) {
            let obj = ''
            switch (val) {
                case 'ACC001':
                    obj = '平台余额账户'
                    break;
                case 'ACC002':
                    obj = '积分账户'
                    break;
                case 'ACC003':
                    obj = '商超账户'
                    break;
                case 'ACC004':
                    obj = '咖吧账户'
                    break;
                case 'ACC005':
                    obj = '家政账户'
                    break;
                case 'ACC006':
                    obj = '洗衣账户'
                    break;
            }
            return obj
        },
        payType(val) {
            let obj = ''
            switch (val) {
                case '01':
                    obj = '支付宝'
                    break;
                case '02':
                    obj = '微信'
                    break;
            }
            return obj
        },
        storedChannelType(val) {
            let obj = ''
            switch (val) {
                case '00':
                    obj = '线上'
                    break;
                case '01':
                    obj = '线下'
                    break;
            }
            return obj
        }

    },
} 